//
//	 ______    ______    ______    
//	/\  __ \  /\  ___\  /\  ___\   
//	\ \  __<  \ \  __\_ \ \  __\_ 
//	 \ \_____\ \ \_____\ \ \_____\ 
//	  \/_____/  \/_____/  \/_____/ 
//
//	Powered by BeeFramework
//
//
//  SafeBoxContentCell.m
//  Pizza
//
//  Created by sendInfo on 2015-04-08.
//  Copyright (c) 2015年 sendInfo. All rights reserved.
//

#import "SafeBoxContentCell.h"
#import "AppDelegate.h"

#pragma mark -

@implementation FooterCell

SUPPORT_AUTOMATIC_LAYOUT( YES )
SUPPORT_RESOURCE_LOADING( YES )

- (void)load
{
    
    self.takeTf = (BeeUITextField*)$(@"takeTf").view;
    
    AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
    app.takeTf = self.takeTf;
    app.moneyTf = (BeeUITextField *)$(@"moneyAccount").view;
    app.shopMoneyLab = (BeeUILabel *)$(@"availableMoney").view;
    
}

- (void)unload
{
}

- (void)dataDidChanged
{
    // TODO: fill data
    NSDictionary *dic = self.data;
    $(@"totalNumber").DATA(dic[@"totalNumber"]);
    $(@"totalProfits").DATA(dic[@"totalProfits"]);

    $(@"availableMoney").DATA(dic[@"availableMoney"]);

    $(@"moneyAccount").DATA(dic[@"moneyAccount"]);

}

@end


@implementation ContentItemCell
SUPPORT_AUTOMATIC_LAYOUT( YES )
SUPPORT_RESOURCE_LOADING( YES )

- (void)load
{
    

}

- (void)unload
{
}

- (void)dataDidChanged
{
    // TODO: fill data
    
    NSDictionary *mydata = self.data;
    id dic = mydata[@"store"];
    if ([dic isKindOfClass:[NSArray class]]) {
        
        NSDictionary *sdic = [dic firstObject];
        NSString *salers = sdic[@"saleMoney"];
        NSString *profit = sdic[@"profit"];
        $(@"shopname").DATA(mydata[@"title"]);
        $(@"salenums").DATA(salers?:@"0");
        $(@"money").DATA(profit?:@"0.00");
    }else{
    
        NSString *salers = dic[@"saleMoney"];
        NSString *profit = dic[@"profit"];
        $(@"shopname").DATA(mydata[@"title"]);
        $(@"salenums").DATA(salers?:@"0");
        $(@"money").DATA(profit?:@"0.00");
    }
    

    

}

@end


@implementation SafeBoxContentCell

SUPPORT_AUTOMATIC_LAYOUT( YES )
SUPPORT_RESOURCE_LOADING( YES )

- (void)load
{
    
    
    NSArray *numBig = @[@"本店",@"一级",@"二级",@"三级",@"四级",@"五级"];
    
    self.list.lineCount = 1;
    self.list.animationDuration = 0.25f;
    self.list.whenReloading = ^{
    
        NSDictionary *dic = self.data;
        NSArray *stores = dic[@"stores"];
        NSDictionary *mystore = dic[@"mystore"];
        NSDictionary *footerd = dic[@"footerdata"];
        
        
        self.list.total = stores.count+1;
        
        
        
        
        for (BeeUIScrollItem *item in self.list.items) {
            

            
            if (item.index < stores.count) {
                
                item.size = CGSizeMake(self.list.width, 30);
                item.clazz = [ContentItemCell class];
                NSString *title = [NSString stringWithFormat:@"%@连锁店",numBig[item.index]];
                if (item.index == 0) {
                    
                    title = @"本店";
                }
                item.data = @{@"title":title,@"store":[stores safeObjectAtIndex:item.index]};
                
                
            }else{
            
                item.size = CGSizeMake(self.list.width, 155);
                item.clazz = [FooterCell class];
                item.data = footerd;
            
            }
        }
    
    };
}

- (void)unload
{
}

- (void)dataDidChanged
{
    // TODO: fill data
    
    [self .list reloadData];
}

- (void)layoutDidFinish
{
    // TODO: custom layout here
}

@end
